package org.zheng.shop.repository;

import java.time.LocalDateTime;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.zheng.shop.entity.ConsultationMessage;

/**
 * 咨询消息Repository
 */
@Repository
public interface ConsultationMessageRepository extends JpaRepository<ConsultationMessage, Long> {
    
    /**
     * 根据会话ID和时间查找消息，按发送时间升序
     */
    List<ConsultationMessage> findBySessionIdAndSentAtAfterOrderBySentAtAsc(Long sessionId, LocalDateTime sentAt);
    
    /**
     * 根据会话ID查找所有消息，按发送时间升序
     */
    List<ConsultationMessage> findBySessionIdOrderBySentAtAsc(Long sessionId);

    /**
     * 根据会话ID删除所有消息
     */
    void deleteBySessionId(Long sessionId);
}
